

#include <stdio.h>
#include <stdlib.h>

// Include serial.
#include <termios.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/signal.h>
#include <sys/types.h>
#include <string.h>


#include "lib_rs_serial.h"

//////////////////////////////////////////////////////  Defines .
#define    MAXSIZE_RXSERIAL_ 1024

#define     PROTO_ASTERIX_   1
#define     PROTO_MAER_      2	
#define     PROTO_ASCII      3    // SMS 
#define     PROTO_HEX        4    // SMS 

typedef struct th_serial_config
{
    int thread_no;
    char channel[80];
    FILE * fd_serial;
    int   protocol:
	int   baud;
	int   databits;
	int   stopbits;
	int   parity;
	
} thinfo_chn;

int wait_flag;                     //TRUE while no signal received



// ******* PROTOTIPOS

void signal_handler_IO (int status);    //definition of signal handler
int  lrs_set_baud ( int baud );
int  lrs_open_serial_port ( char * devicename, char block );
void lrs_close (FILE * fd );
void lrs_printoutmode ( int format );     //testes
int  lrs_set_parms ( int chsz, int parity , int  stopbits ); // mudar,nao gostei.


// ret =  lrs_receive frame ( PROTO_HEX, fd , buffer );
int  lrs_receive frame ( int proto, void * fdrx, char * rxbuf );



/*************************************************************************** 
* signal handler. sets wait_flag to FALSE, to indicate above loop that     *
* characters have been received.                                           *
***************************************************************************/
void signal_handler_IO (int status)
{
    printf("received SIGIO signal.\n");
   wait_flag = FALSE_;
}

